import request from '@/utils/request'

// 用户登录
export const login = (data: { account: string; password: string }) => {
  return request({
    url: '/user/login',
    method: 'POST',
    data
  })
}

// 用户注册
export const register = (data: { 
  account: string
  password: string
  name: string
  signature?: string
  avatar?: string
  role?: string
}) => {
  return request({
    url: '/user/addUser',
    method: 'POST',
    data
  })
}

// 获取用户信息
export const getUserInfo = (data: { user_id: number }) => {
  return request({
    url: '/user/getUserById',
    method: 'POST',
    data
  })
}

// 用户注销
export const logout = () => {
  return request({
    url: '/user/logout',
    method: 'POST'
  })
}

// 获取用户列表
export const getUserList = () => {
  return request({
    url: '/user/getUser',
    method: 'POST'
  })
}

// 更新用户信息
export const updateUserInfo = (data: {
  user_id: number
  account?: string
  password?: string
  name?: string
  signature?: string
  avatar?: string
  avatar_upload_id?: number
  role?: string
}) => {
  return request({
    url: '/user/updateUser',
    method: 'POST',
    data
  })
}

// 删除用户
export const deleteUser = (data: { user_id: number }) => {
  return request({
    url: '/user/deleteUser',
    method: 'POST',
    data
  })
}

// 批量删除用户
export const batchDeleteUsers = (data: { user_ids: number[] }) => {
  return request({
    url: '/user/batchDeleteUser',
    method: 'POST',
    data
  })
}